﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;

namespace _15梁佩雯
{
    public partial class _default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            
            string strCn = "server=pc.hstc.cn;database=dhd2014112115;uid=2014112115;pwd=19951025";
            if (userName.Text == "")
            {
                Response.Write("<script>alert('用户名不能为空！')</script>");
                userName.Focus();
            }
            else
                if (userPass.Text == "")
                {
                    Response.Write("<script>alert('密码不能为空！')</script>");
                    userPass.Focus();
                }
            string strSQL = "select * from UserInfo where UserName='" + userName.Text + "'  AND  Password='" + userPass.Text + "'";
            SqlConnection conn = new SqlConnection(strCn);
            conn.Open();
            DataSet ds = new DataSet();
            SqlDataAdapter sql = new SqlDataAdapter(strSQL, conn);
            sql.Fill(ds);
            conn.Close();
            if (ds.Tables[0].Rows.Count > 0)
            {
                Response.Redirect("Web.aspx");
            }
            else
            {
                Response.Write("<script>alert('用户名或密码错误')</script>");
            }
        }

        protected void Sign_Click(object sender, EventArgs e)
        {

        }
       
    }
}
        
    
